﻿using Hotel.Booking.ReservationWS.Common.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Hotel.OTA.Service.Common.Utility;
using Hotel.Alliance.CommonEsLib.Tools;
using System.IO;
using Microsoft.VisualBasic.FileIO;
using System.Reflection;
using Csv;
using Hotel.Hotelalliance.Hotelallianceorderservice;
using CServiceStack.ServiceClient;
using RestSharp;
using System.Diagnostics;
using Jair_ConsoleApplication.protobuf;
using ProtoBuf;
using System.Runtime.Serialization.Formatters.Binary;
using Hotel.OTA.Service.Data.DB.Entity;
using Hotel.Alliance.OrderDataCache;
using Hotel.Alliance.OrderDataCache.Cache;

namespace Jair_ConsoleApplication
{
    class Program
    {
        public  decimal MinPriceBeforeTaxArea { get; set; }
        public static void Main(string[] args)
        {
            ////------------------------------------------------------测试：空值----------------------------------------------------------
            //Program j = new Program();
            //Console.WriteLine(j.MinPriceBeforeTaxArea.ToString());
            ////Console.WriteLine("请输入您的值1=");
            ////string str1 = Console.ReadLine();
            ////Console.WriteLine("请输入您的值2=");
            ////string str2 = Console.ReadLine();
            ////Console.WriteLine("您输入的值1是{0},值2是{1}.",str1,str2);
            ////Console.ReadLine();//控制台应用程序执行一闪而过解决方法一
            ////Console.ReadKey();//控制台应用程序执行一闪而过解决方法二
            //////方法三：运行程序的时不用F5键执行，用Ctrl+F5执行，它的意思是“启动执行（不调试）”。
            ////------------------------------------------------------测试：加密----------------------------------------------------------

            //Test1();
            //------------------------------------------------------测试：原子锁----------------------------------------------------------
            //Test2();
            //------------------------------------------------------测试：性能----------------------------------------------------------
            //getDate();
            //------------------------------------------------------测试：时间----------------------------------------------------------
            //Test3();
            //------------------------------------------------------测试：RateCode----------------------------------------------------------
            //Test4();
            //------------------------------------------------------测试：姓名测试----------------------------------------------------------
            //Test5();
            //------------------------------------------------------测试：LOGID----------------------------------------------------------
            //Test6();
            //------------------------------------------------------测试：基础数据----------------------------------------------------------
            //Test7();
            //------------------------------------------------------测试：日志解压----------------------------------------------------------
            //Test8();
            //------------------------------------------------------测试：百分数转换----------------------------------------------------------
            //Test9();
            //------------------------------------------------------测试：字符串校验----------------------------------------------------------
            //Test10();
            //------------------------------------------------------测试：加密----------------------------------------------------------
            //Test11();
            //------------------------------------------------------测试：加密----------------------------------------------------------
            //Test12();
            //------------------------------------------------------测试：最晚到店时间校验----------------------------------------------------------
            //Test13();
            //------------------------------------------------------测试：时间格式化----------------------------------------------------------
            //Test14();
            //------------------------------------------------------测试：枚举----------------------------------------------------------
            //Test15();
            //------------------------------------------------------测试：CSV----------------------------------------------------------
            //Test16();
            //------------------------------------------------------测试：CSV----------------------------------------------------------
            //Test17();
            //------------------------------------------------------测试：CSV中英文信息----------------------------------------------------------
            //Test18();
            //------------------------------------------------------测试：进位测试----------------------------------------------------------
            //Test19();
            //------------------------------------------------------测试：进位测试----------------------------------------------------------
            //Test20();
            //------------------------------------------------------测试：进位测试----------------------------------------------------------
            //Test21();
            //------------------------------------------------------测试：时间测试----------------------------------------------------------
            //Test22();
            //------------------------------------------------------测试：进位测试----------------------------------------------------------
            //Test23();
            //------------------------------------------------------测试：时间戳与Java同步----------------------------------------------------------
            //Test24();
            //------------------------------------------------------测试：支付有效期问题----------------------------------------------------------
            //Test25();
            //------------------------------------------------------测试：时间戳与Java同步----------------------------------------------------------
            //Test26();
            //------------------------------------------------------测试：时间戳与Java同步----------------------------------------------------------
            //Test27();
            //------------------------------------------------------测试：时间戳与Java同步----------------------------------------------------------
            //Test28();
            //------------------------------------------------------测试：protobuf测试----------------------------------------------------------
            //Test29();
            //------------------------------------------------------测试：protobuf测试----------------------------------------------------------
            //Test30();
            //------------------------------------------------------测试：protobuf测试----------------------------------------------------------
            //Test31();
            //------------------------------------------------------测试：最早到店时间----------------------------------------------------------
            //Test32();
            //------------------------------------------------------测试：信用卡时间问题----------------------------------------------------------
            //Test33();
            Test34();
        }
        private static void Test00()
        {
        }

        private static void Test34()
        {
            GuaranteeTypeEnum guaranteeType = new GuaranteeTypeEnum();
            Enum.TryParse("1", true, out guaranteeType);
            Console.WriteLine(guaranteeType.ToString());
        }

        private static void Test33()
        {
            int effectiveYear = 0;
            int effectiveMonth = 0;
            if (!int.TryParse("20" + "0420".Substring(2, 2), out effectiveYear))
            {
                Console.WriteLine(false);
            }
            if (!int.TryParse("0420".Substring(0, 2), out effectiveMonth))
            {
                Console.WriteLine(false);
            }
            Console.WriteLine(effectiveMonth);
            Console.WriteLine(effectiveYear);
        }

        private static void Test32()
        {
            Console.WriteLine("meta-us-4778".Replace("-", "_"));
            string abc = string.Empty;
            string campaignIDStr = CombineValue(abc, "88");
            Console.WriteLine(campaignIDStr);
        }
        /// <summary>
        /// Combine strings with commas.
        /// </summary>
        public static string CombineValue(string value, string newValue)
        {
            List<string> sArray = value.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
            if (sArray != null && sArray.Count > 0)
            {
                sArray.Add(newValue);
                return string.Join(",", sArray);
            }
            else
            {
                return newValue;
            }
        }

        private static void Test31()
        {
            List<string> ipconfigs = new List<string>();
            ipconfigs.Add("10.*");
            bool isExist = CheckIPs(ipconfigs, "10.22.16.121");
            Console.WriteLine(isExist);
        }
        private static bool CheckIPs(List<string> ipconfigs, string ip)
        {
            bool check = false;
            foreach (var ipcfg in ipconfigs)
            {
                String[] arr_Source = ipcfg.Split('.');
                String[] arr_str = ip.Split('.');
                bool flag = true;
                for (int i = 0; i < arr_Source.Length; i++)
                {
                    if ((!arr_Source[i].Equals("*")) && (!arr_Source[i].Equals(arr_str[i])))
                    {
                        flag = false;
                    }
                }
                if (flag)
                {
                    check = true;
                    break;
                }
            }
            return check;
        }

        private static void Test30()
        {
            Alliance_Distributor_OTAHotelOrder ado = new Alliance_Distributor_OTAHotelOrder();
            ado.AllianceID = 1;
            ado.OrderAmount = new decimal(123.4652);
            ado.CheckOutTime = DateTime.Now;
            ProtobufHelper.Serialize<Alliance_Distributor_OTAHotelOrder>("Test.txt", ado);

            Alliance_Distributor_OTAHotelOrder newlist1 = ProtobufHelper.DeSerialize<Alliance_Distributor_OTAHotelOrder>(new FileInfo("Test.txt").OpenRead());
            Console.WriteLine(newlist1.ToString());


        }
        private static void Test29()
        {
            Person one = new Person() { Name = "A", age = 18, weight = 40 };
            Person two = new Person() { Name = "B", age = 15, weight = 44 };
            List<Person> people = new List<Person>() { one, two };
            //序列化字符
            string temp = ProtobufHelper.Serialize<List<Person>>(people);
            //序列化到文件
            ProtobufHelper.Serialize<List<Person>>("Test.txt", people);
            Console.WriteLine(temp);
            //反序列化字符
            List<Person> newlist = ProtobufHelper.DeSerialize<List<Person>>(temp);
            for (int i = 0; i < newlist.Count; i++)
            {
                Console.WriteLine(newlist[i].ToString());
            }
            //反序列化字符
            List<Person> newlist1 = ProtobufHelper.DeSerialize<List<Person>>(new FileInfo("Test.txt").OpenRead());
            for (int i = 0; i < newlist1.Count; i++)
            {
                Console.WriteLine(newlist1[i].ToString());
            }
            while (true)
            { }

            Alliance_Distributor_OTAHotelOrder abc = new Alliance_Distributor_OTAHotelOrder();
            MemoryStream ms = new MemoryStream();
            BinaryFormatter bm = new BinaryFormatter();
            bm.Serialize(ms, abc);
            //Serializer.Serialize<Person>(ms, abc);
            byte[] data = ms.ToArray();//length=27  709
        }
        private static void Test28()
        {
            string start = "2020-01-13 02:30:00";
            DateTime startTime = DateTime.ParseExact(start, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
            string end = "2020-01-18 03:45:00";
            DateTime endTime = DateTime.ParseExact(end, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);

            Console.WriteLine(startTime.ToString());
            Console.WriteLine(endTime.ToString());
            var info = (endTime - startTime).Minutes;
            Console.WriteLine(info);
            Console.WriteLine(info > 10);

        }

        private static void Test27()
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            IDictionary<string, string> indexedTags = new Dictionary<string, string>();
            indexedTags.Add("111", "111");
            indexedTags.Add("222", "222");
            indexedTags.Add("333", "333");
            indexedTags.Add("444", "444");
            indexedTags.Add("555", "555");
            indexedTags.Add("666", "666");
            indexedTags.Add("777", "777");
            indexedTags.Add("888", "888");
            indexedTags.Add("999", "999");
            indexedTags.Add("1110", "1110");
            indexedTags.Add("1221", "1221");
            indexedTags.Add("1332", "1332");
            indexedTags.Add("1443", "1443");
            indexedTags.Add("1554", "1554");
            indexedTags.Add("1665", "1665");
            indexedTags.Add("1776", "1776");
            indexedTags.Add("1887", "1887");
            indexedTags.Add("1998", "1998");
            indexedTags.Add("2109", "2109");
            indexedTags.Add("2220", "2220");
            indexedTags.Add("2331", "2331");
            indexedTags.Add("2442", "2442");
            indexedTags.Add("2553", "2553");
            indexedTags.Add("2664", "2664");
            indexedTags.Add("2775", "2775");
            indexedTags.Add("2886", "2886");
            indexedTags.Add("2997", "2997");
            indexedTags.Add("3108", "3108");
            indexedTags.Add("3219", "3219");
            indexedTags.Add("3330", "3330");
            indexedTags.Add("3441", "3441");
            indexedTags.Add("3552", "3552");
            indexedTags.Add("3663", "3663");
            indexedTags.Add("3774", "3774");
            indexedTags.Add("3885", "3885");
            indexedTags.Add("3996", "3996");
            indexedTags.Add("4107", "4107");
            indexedTags.Add("4218", "4218");
            indexedTags.Add("4329", "4329");
            indexedTags.Add("4440", "4440");
            indexedTags.Add("4551", "4551");
            indexedTags.Add("4662", "4662");
            indexedTags.Add("4773", "4773");
            indexedTags.Add("4884", "4884");
            indexedTags.Add("4995", "4995");
            indexedTags.Add("5106", "5106");
            indexedTags.Add("5217", "5217");
            indexedTags.Add("5328", "5328");
            indexedTags.Add("5439", "5439");
            indexedTags.Add("5550", "5550");
            indexedTags.Add("5661", "5661");
            indexedTags.Add("5772", "5772");
            indexedTags.Add("5883", "5883");
            indexedTags.Add("5994", "5994");
            indexedTags.Add("6105", "6105");
            indexedTags.Add("6216", "6216");
            indexedTags.Add("6327", "6327");
            indexedTags.Add("6438", "6438");
            indexedTags.Add("6549", "6549");
            indexedTags.Add("6660", "6660");
            indexedTags.Add("6771", "6771");
            indexedTags.Add("6882", "6882");
            indexedTags.Add("6993", "6993");
            indexedTags.Add("7104", "7104");
            indexedTags.Add("7215", "7215");
            indexedTags.Add("7326", "7326");
            indexedTags.Add("7437", "7437");
            indexedTags.Add("7548", "7548");
            indexedTags.Add("7659", "7659");
            indexedTags.Add("7770", "7770");
            indexedTags.Add("7881", "7881");
            indexedTags.Add("7992", "7992");
            indexedTags.Add("8103", "8103");
            indexedTags.Add("8214", "8214");
            indexedTags.Add("8325", "8325");
            indexedTags.Add("8436", "8436");
            indexedTags.Add("8547", "8547");
            indexedTags.Add("8658", "8658");
            indexedTags.Add("8769", "8769");
            indexedTags.Add("8880", "8880");
            indexedTags.Add("8991", "8991");
            indexedTags.Add("9102", "9102");
            indexedTags.Add("9213", "9213");
            indexedTags.Add("9324", "9324");
            indexedTags.Add("9435", "9435");
            indexedTags.Add("9546", "9546");
            indexedTags.Add("9657", "9657");
            indexedTags.Add("9768", "9768");
            indexedTags.Add("9879", "9879");
            indexedTags.Add("9990", "9990");
            indexedTags.Add("10101", "10101");
            indexedTags.Add("10212", "10212");
            indexedTags.Add("10323", "10323");
            indexedTags.Add("10434", "10434");
            indexedTags.Add("10545", "10545");
            indexedTags.Add("10656", "10656");
            indexedTags.Add("10767", "10767");
            indexedTags.Add("10878", "10878");
            indexedTags.Add("10989", "10989");
            indexedTags.Add("11100", "11100");

            string[] keys = {"333", "444", "555", "666", "777", "888", "999", "1110", "1221", "1332", "1443", "1554", "1665", "1776", "1887", "1998", "2109", "2220", "2331", "2442", "2553", "2664", "2775", "2886", "2997", "3108", "3219", "3330", "3441", "3552", "3663", "3774", "3885", "3996", "4107", "4218", "4329", "4440", "4551", "4662", "4773", "4884", "4995", "5106", "5217", "5328", "5439", "5550", "5661", "5772", "5883", "5994", "6105", "6216", "6327", "6438", "6549", "6660", "6771", "6882", "6993", "7104", "7215", "7326", "7437", "7548", "7659", "7770", "7881", "7992", "8103", "8214", "8325", "8436", "8547", "8658", "8769", "8880", "8991", "9102", "9213", "9324", "9435", "9546", "9657", "9768", "9879", "9990", "10101", "10212", "10323", "10434", "10545", "10656", "10767", "10878", "10989", "11100" };
            Console.WriteLine(indexedTags.Count);
            foreach (string key in keys)
            {
                if (indexedTags.ContainsKey(key))
                {
                    indexedTags.Remove(key);
                }
            }
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
            Console.WriteLine(indexedTags.Count);


        }


        private static void Test26()
        {
            //http://restsharp.org/
            var client = new RestClient("http://ws.unioncritical.hotel.fws.qa.nt.ctripcorp.com/otabooking/api/json/ota_hotelressave?aid=1&sid=271");
            client.Timeout = -1;
            var request = new RestRequest(Method.POST);
            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("application/json", "{\r\n    \"UniqueID\": [\r\n        {\r\n            \"Type\": \"1\",\r\n            \"ID\": \"dc5ce3bf-b10e-4628-b7f0-0225cf7bb524\"\r\n        },\r\n        {\r\n            \"Type\": \"28\",\r\n            \"ID\":  1\r\n        },\r\n        {\r\n            \"Type\": \"503\",\r\n            \"ID\":  271\r\n        }, \r\n        {\r\n        \"Type\": \"504\",\r\n        \"ID\": \"20170331001\"\r\n    \t}\r\n    ],\r\n    \"HotelReservations\": {\r\n        \"HotelReservation\": {\r\n            \"RoomStays\": {\r\n                \"RoomStay\": {\r\n                    \"RoomTypes\": {\r\n                        \"RoomType\": {\r\n                            \"NumberOfUnits\": 1\r\n                        }\r\n                    },\r\n                    \"RatePlans\": {\r\n                        \"RatePlan\": {\r\n                            \"RatePlanCode\": 2725125,\r\n                            \"RoomID\": 2725125,\r\n                            \"RatePlanCategory\": \"16\",\r\n                            \"PrepaidIndicator\": false,\r\n                            \"BookingCode\": null,\r\n                            \"RatePlanID\": null\r\n                        }\r\n                    },\r\n                    \"BasicPropertyInfo\": {\r\n                        \"HotelCode\": 11315373\r\n                    }\r\n                }\r\n            },\r\n            \"ResGuests\": {\r\n                \"ResGuest\": {\r\n                    \"Profiles\": {\r\n                        \"ProfileInfo\": {\r\n                            \"Profile\": {\r\n                                \"Customer\": {\r\n                                    \"PersonName\": [\r\n                                        {\r\n                                            \"Name\": \"Jacob/Mendelson\"\r\n                                        }\r\n                                    ],\r\n                                    \"ContactPerson\": {\r\n                                        \"PersonName\": {\r\n                                            \"Name\": \"Smith/John\"\r\n                                        },\r\n                                        \"Telephone\": [\r\n                                            {\r\n                                                \"PhoneTechType\": \"1\",\r\n                                                \"PhoneNumber\": \"+86-18516550405\"\r\n                                            }\r\n                                        ],\r\n                                        \"Email\": \"chunfang@163.com\",\r\n                                        \"ContactType\": \"tel\"\r\n                                    }\r\n                                }\r\n                            }\r\n                        }\r\n                    },\r\n                    \"TPA_Extensions\": {\r\n                        \"LateArrivalTime\": \"2020-01-07 13:00:00\"\r\n                    }\r\n                }\r\n            },\r\n            \"ResGlobalInfo\": {\r\n                \"GuestCounts\": {\r\n                    \"GuestCount\": {\r\n                        \"Count\": 1\r\n                    }\r\n                },\r\n                \"TimeSpan\": {\r\n                    \"Start\":\"2020-01-07 13:00:00\",\r\n                    \"End\": \"2020-01-08 11:00:00\"\r\n                },\r\n\r\n                \"DepositPayments\": [\r\n                    {\r\n                        \"AmountPercent\": {\r\n                            \"Amount\": 141.0000,\r\n                            \"CurrencyCode\": \"CNY\"\r\n                        },\r\n                        \"GuaranteeCode\": \"2\",\r\n                        \"GuaranteeType\": \"CCDCVoucher\"\r\n                    }\r\n                ],\r\n                \"Total\": {\r\n                    \"ExclusiveAmount\": 379,\r\n                    \"InclusiveAmount\": 379,\r\n                    \"CurrencyCode\": \"CNY\"\r\n                },\r\n                \"TPA_Extensions\": {\r\n                    \"Invoice\": {\r\n                        \"ContactInfo\": {\r\n                            \"PersonName\": \"Smith/John\",\r\n                            \"Telephone\": [\r\n                                {\r\n                                    \"PhoneTechType\": \"1\",\r\n                                    \"PhoneNumber\": \"+86-18516550405\"\r\n                                }\r\n                            ],\r\n                            \"Email\": \"chunfang@163.com\"\r\n                        },\r\n                        \"PostAddress\": {\r\n                            \"AddressLine\": \"No.158,Henshan Rd.,Xuhui District,Shanghai\",\r\n                            \"PostalCode\": \"231600\"\r\n                        },\r\n                        \"Body\": \"Accommondation Fee\",\r\n                        \"FullDescription\": \"hotel accommation fee for Smith John and Chunfang Chen\",\r\n                        \"ShortDescription\": \"Private trip to Shanghai\",\r\n                        \"Title\": \"ABC Corporation\"\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    },\r\n    \"TimeStamp\": \"2020-01-07\",\r\n    \"Version\": 1,\r\n    \"PrimaryLangID\": \"en\",\r\n    \"TransactionIdentifier\": \"b087d508bedd51b5791d54e246125542\"\r\n}", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);
            Console.WriteLine(response.Content);
        }
            
        private static void Test25()
        {
            string abc = "2222";
            int effectiveYear = 0;
            int effectiveMonth = 0;
            //int.TryParse(abc.Substring(0, 2), out effectiveMonth);
            //int.TryParse("20" + abc.Substring(2, 2), out effectiveYear);
            string dddd = effectiveYear.ToString() + effectiveMonth.ToString("00");
            Console.WriteLine(dddd);

        }
        private static void Test24()
        {
            DateTime time = DateTime.Now;
            Console.WriteLine(time);
            long timestampJava = (time.ToUniversalTime().Ticks - 621355968000000000) / 10000;
            Console.WriteLine(timestampJava);
            string time1 = Convert.ToInt64(timestampJava / 1000 / 60).ToString();
            Console.WriteLine(time1);

        }
        private static void Test23()
        {
            int i = 0;
            Console.WriteLine(i++);
            Console.WriteLine(i++);
            Console.WriteLine(i++);
            Console.WriteLine(i++);
            Console.WriteLine(i++);
        }
        private static void Test22()
        {
            Console.WriteLine(DateTime.Now.ToString());
            Console.WriteLine(DateTime.Now.AddHours(24));
            DateTime EffectiveDate = DateTime.Now.AddHours(24 - 9999);
            Console.WriteLine(EffectiveDate.ToString());
        }

        private static void Test21()
        {
            ServiceClientBase.AppId = "110802";
            ServiceClientBase.ServiceRegistryTestSubEnv = "FWS";
            ServiceClientBase.ServiceRegistryUrl = "http://ws.soa.fws.qa.nt.ctripcorp.com/registry/api";
            GetAllianceDetailInfoAsyncRequestType request = new GetAllianceDetailInfoAsyncRequestType();
            request.SearchCandidate = new AllianceInfoCandidateType();
            request.SearchCandidate.AllianceID = 1;
            request.SearchCandidate.SID = 50;
            HotelAllianceOrderServiceClient client = HotelAllianceOrderServiceClient.GetInstance();
            GetAllianceDetaiInfoAsyncResponseType response = client.GetAllianceDetailInfo(request);
            String name = response.AllianceDetailInfos.AllianceName;
        }
        private static void Test20()
        {
            decimal a = (10 - null ?? 0);
            decimal OrderCostAmount = 0 + a * 2;
            Console.WriteLine("分销" + OrderCostAmount);
        }
                
        private static void Test19()
        {
            //decimal moneyError = new decimal(552.283713);
            //decimal money = new decimal(227.75511);
            //string abc = Math.Round(Convert.ToDecimal(new decimal(0.909545)) * 1.00M, 5, MidpointRounding.AwayFromZero).ToString();
            //decimal haremoney = new decimal(957.98025);
            //decimal.Round(haremoney * 1.00M, haremoney);

            //int count = 4;
            //decimal exchange = new decimal(1.0);
            //Console.WriteLine("分销" + abc);
            //Console.WriteLine("底层" + FormatMoneyuper(haremoney, count));
        }

        /// <summary>
        /// 进位逻辑
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static decimal FormatMoneyuper(decimal amount, int count)
        {
            return FormatMoneyuperDetail(amount, new decimal(1), count);
        }

        /// <summary>
        /// 进位逻辑
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static decimal FormatMoneyuperDetail(decimal amount, decimal exchange, int count)
        {
            var uper = count <= 0 ? 1 : (int)Math.Pow(10, count);
            var result = (amount / exchange) * uper;
            result = Math.Ceiling(result);
            result = result / uper;
            return result;
        }

        /// <summary>
        /// 格式化金额为保留4位小数
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static decimal FormatMoney(decimal number)
        {
            return FormatMoney(number, 4);
        }

        /// <summary>
        /// 格式化金额为保留小数
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static decimal FormatMoney(decimal number, int decimals)
        {
            //return decimal.Round(number * 1.00M, decimals);
            return Math.Round(number, decimals, MidpointRounding.AwayFromZero);
        }

        /// <summary>
        /// 格式化金额为保留小数
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static decimal FormatMoney(decimal amount, decimal exchangeRate)
        {
            return Math.Round(amount * exchangeRate, 4, MidpointRounding.AwayFromZero);
        }

        private static void Test18()
        {
            ErrorInfoHelper errorInfoHelper = ErrorInfoHelper.Instance;
            List<ErrorInfoModel> info = errorInfoHelper.LoadData();
            List<ErrorInfoModel> info1 = errorInfoHelper.LoadData1();
            List<ErrorInfoModel> info2 = errorInfoHelper.LoadData2();
            List<ErrorInfoModel> info3 = errorInfoHelper.LoadDataGJ();
            foreach (var line in info)
            {
                Console.WriteLine(string.Format("{0}——{1}", line.CN, line.EN));
            }
        }
        private static void Test16()
        {
            Assembly ass = Assembly.GetExecutingAssembly();
            string resFullName = string.Format("{0}.Resources.{1}", ass.GetName().Name, "ErrorCodeResource.csv");
            IEnumerable<ErrorInfoModel> errorList = LoadCustomerList("ErrorCodeResource.csv");
            foreach (var error in errorList)
            {
                Console.WriteLine(" {0} -{1}", error.CN, error.EN);

            }
            Console.ReadKey();
        }
        private static void Test17()
        {
            var csv = File.ReadAllText("ErrorCodeResource.csv");
            List<ErrorInfoModel> customerList = new List<ErrorInfoModel>();
            var options = new CsvOptions // Defaults
            {
                RowsToSkip = 0, // Allows skipping of initial rows without csv data
                SkipRow = (row, idx) => string.IsNullOrEmpty(row) || row[0] == '#',
                Separator = '\0', // Autodetects based on first row
                TrimData = false, // Can be used to trim each cell
                Comparer = null, // Can be used for case-insensitive comparison for names
                HeaderMode = HeaderMode.HeaderPresent, // Assumes first row is a header row
                ValidateColumnCount = false, // Checks each row immediately for column count
                ReturnEmptyForMissingColumn = false, // Allows for accessing invalid column names
                Aliases = null, // A collection of alternative column names
            };
            foreach (var line in CsvReader.ReadFromText(csv, options))
            {
                ErrorInfoModel error = new ErrorInfoModel();
                error.ErrorCode = line[0];
                Encoding ec = Encoding.Default;
                byte[] btArr = ec.GetBytes(line[2]);
                string strBuffer = Encoding.Default.GetString(btArr);

                error.CN = strBuffer;
                error.EN = line[3];
                customerList.Add(error);
            }
            Console.WriteLine(customerList.Count);
        }
        private static IEnumerable<ErrorInfoModel> LoadCustomerList(string fileName)
        {
            List<ErrorInfoModel> customerList = new List<ErrorInfoModel>();

            using (TextFieldParser parser = new TextFieldParser(fileName))
            {
                parser.Delimiters = new string[] { "," };
                parser.HasFieldsEnclosedInQuotes = true;

                string[] fields;
                while ((fields = parser.ReadFields()) != null)
                {
                    ErrorInfoModel error = new ErrorInfoModel();
                    error.ErrorCode = fields[0];
                    error.CN = fields[1];
                    error.EN = fields[2];
                    customerList.Add(error);
                }
            }
            return customerList;
        }

        private static void Test15()
        {
            Jair_ConsoleApplication.ProgramEnum.InternalError pEarth = Jair_ConsoleApplication.ProgramEnum.InternalError.orderdeal_110117020013;
            string earthRadius = pEarth.Type; 
            foreach (Jair_ConsoleApplication.ProgramEnum.InternalError p in Jair_ConsoleApplication.ProgramEnum.InternalError.Values)
            //Console.WriteLine(" {0} -{1}", p, p.getEn(mass));
            Console.ReadKey();
        }

        private static void Test14()
        {
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ssfffffffzzzz"));
            string checkTime = "2019-06-08 01:50:00";
            DateTime endcheck = DateTime.ParseExact(checkTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
            endcheck.ToLocalTime();
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            Console.WriteLine(timeZone.DaylightName);
            Console.WriteLine(timeZone.StandardName);
            TimeZoneInfo UTC_8 = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");//-8
            TimeZoneInfo local = TimeZoneInfo.Local;
            Console.WriteLine(UTC_8.BaseUtcOffset);
            Console.WriteLine(local.BaseUtcOffset);

            Console.WriteLine(LocatTimeToUTC.ToUTC(-54000));
        }

        private static DateTime GetEarlyArrivalTime(string time, DateTime start, DateTime earlyArrivalTime)
        {
            DateTime arrivalTime = DateTime.MinValue;
            DateTime.TryParse(time, out arrivalTime);
            if (arrivalTime != DateTime.MinValue)
            {
                earlyArrivalTime = start.Date.AddTicks(arrivalTime.TimeOfDay.Ticks);
            }
            return earlyArrivalTime;
        }

        private static void Test13()
        {
            DateTime start = DateTime.Now;
            DateTime earlyArrivalTime=DateTime.MinValue;
            earlyArrivalTime = GetEarlyArrivalTime("12:50:00", start, earlyArrivalTime);
            Console.WriteLine(earlyArrivalTime);


            DateTime arrivalTime = DateTime.MinValue;
            DateTime.TryParse("12:50:00", out arrivalTime);
            if (arrivalTime != DateTime.MinValue)
            {
                DateTime aa = start.Date.AddTicks(arrivalTime.TimeOfDay.Ticks);
            }


            string checkTime = "2019-06-08 01:50:00";
            DateTime checkDateTime = DateTime.MinValue;
            bool result=DateTime.TryParse(checkTime, out checkDateTime);
            if (result)
            {
                checkDateTime = DateTime.ParseExact(checkTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
                bool begin = DateTime.Now <= checkDateTime;
                DateTime endcheck = DateTime.Now.AddHours(36);
                bool end = checkDateTime <= endcheck;
                if (begin && end)
                {
                    Console.WriteLine("满足条件");
                }
                else
                {
                    Console.WriteLine("不满足条件");
                }
            }
        }

        private static void Test12()
        {
            string value = "{\"head\":{\"version\":\"1.0.0.1\",\"platform\":\"30\",\"serviceCode\":\"41003003\",\"merchantId\":\"200003\",\"auth\":\"_A20170310185743612\",\"orderId\":\"3068420517\",\"requestId\":\"0\",\"language\":\"ZH\",\"clientIp\":\"10.32.120.146\",\"guid\":\"35089be3-cfd7-4dfd-96c1-3222c233ef6a\",\"token\":\"F2F80D810D6B6E59F65060C1525392FE\"},\"paymentVersion\":\"2.0.1\",\"interfaceName\":\"SubmitCardInfo\",\"transactionId\":\"2RULL2AD8MXHK8ZW4J48NESKWP\",\"amount\":\"666.0000\",\"currencyCode\":\"CNY\",\"customerName\":\"_A20170310185743612\",\"obligedFields\":\"{\\\"card_holder\\\":true,\\\"validity\\\":true,\\\"verify_no\\\":true,\\\"idcard_no\\\":false,\\\"idcard_type\\\":false,\\\"phone_no\\\":false,\\\"foreign_phone_no\\\":false,\\\"pass_word\\\":false,\\\"phone_verify_no\\\":false,\\\"email\\\":false,\\\"birthday\\\":false}\",\"validFields\":\"{\\\"card_holder\\\":true,\\\"validity\\\":true,\\\"verify_no\\\":true,\\\"idcard_no\\\":false,\\\"idcard_type\\\":false,\\\"phone_no\\\":false,\\\"foreign_phone_no\\\":false,\\\"pass_word\\\":false,\\\"phone_verify_no\\\":false,\\\"email\\\":false,\\\"birthday\\\":false}\",\"chargeMode\":\"4\",\"cardInfo\":{\"cardNo\":{\"content\":\"eJ2FgJ***Pa\",\"encrypt\":\"CtripEnc\"},\"expiryDate\":{\"content\":\"***\",\"encrypt\":\"CtripEnc\"},\"cardVerifyNo\":{\"content\":\"***\",\"encrypt\":\"CtripEnc\"},\"cardHolder\":\"***\",\"idCardType\":\"400\",\"idCardNo\":\"***\",\"phoneNumber\":\"177***8442\",\"smsCode\":{}},\"payRequestExtend\":\"RecallType=SOA20:http://webapi.soa.fws.qa.nt.ctripcorp.com/api/12761/json/billcallback&PaymentNotify=http://ws.reservation.hotel.fws.qa.nt.ctripcorp.com/Hotel-Booking-ReservationWS/api/RepaymentService/PaymentNotify&IsRealTimePay=0&IsAutoApplyBill=1&IsGuaranteePay=1&IsNeedPreAuth=0&Payee=2\"}";

            string result = StringCompressionHelper.GZipCompressString(value.Trim());

            Console.WriteLine(result);
        }

        private static void Test11()
        {
            string abc = "ZNY+deb7tsU3kL1fcv+1aEELHKksHm9ikhsuJrKi3nb456sLAvOa/2RmhkRgQyigsb1AjYh5s32qfubS/1JVFOgw9lJw56mT5kaX/ol9d37oxiGtPLTJalYdfCEq2FdxfF6c2XbO/y9zST29Lmoqw8W7oe2Bdl4Xg3OBRjU5QG2ysEEDf1bu4w4uRoIxp96RZpaQGy6HUwNyD+atM7JY+GmJ7B5HhJ1r0nreBlXY86XpM0xZJU9q0Euyr1dv8usnrLQeWbBFf9aaqj1wfo8udQ==";
            string encry = AESHelper.Encrypt("ABC", "100004682");

            Console.WriteLine(encry);

            string decry = AESHelper.Decrypt(abc, "100005457");

            Console.WriteLine(decry);
        }

        private static void Test10()
        {
            //Regex regExp = new Regex("[ \\[ \\] \\^ \\-_*×――(^)$%~!@#$…&%￥—+=<>《》!！??？:：•`·、。，；,.;\"‘’“”-]"); 
            string abc = "Goutam/Siddhartha Kumar Kumar";
            string name = "ABC•ABC";
            List<UserNameModel> nameList = new List<UserNameModel>();
            nameList.Add(new UserNameModel() { Name = "方1", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "方YJ", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "方／／", Type = "一", Result = "XXXXX" });

            nameList.Add(new UserNameModel() { Name = "F/Y/J", Type = "一", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "F.Y.J", Type = "一", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "F-Y-J", Type = "一", Result = "成功" });

            nameList.Add(new UserNameModel() { Name = "FYJ1", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "FYJ*", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "/Y/J", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "-Y/J-", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "---", Type = "一", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "...", Type = "一", Result = "XXXXX" });

            nameList.Add(new UserNameModel() { Name = "加孜拉•吐尔德别克", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "加孜.吐尔德别克", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "马依努尔·巴克尔", Type = "二", Result = "成功" });

            nameList.Add(new UserNameModel() { Name = "加孜拉••吐尔德别克", Type = "二", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "加孜.吐尔德别克.吐尔德别克", Type = "二", Result = "XXXXX" });

            nameList.Add(new UserNameModel() { Name = "ABC•ABC", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "ABC.ABC", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "ABC.ABC.ABC", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "ABC•ABC/ABC", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "FirstName MiddleName LastName", Type = "二", Result = "成功" });

            nameList.Add(new UserNameModel() { Name = "ABC••ABC", Type = "二", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "ABC//ABC", Type = "二", Result = "XXXXX" });
            nameList.Add(new UserNameModel() { Name = "ABC  ABC", Type = "二", Result = "XXXXX" });

            nameList.Add(new UserNameModel() { Name = "   张三", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "张   三", Type = "二", Result = "成功" });
            nameList.Add(new UserNameModel() { Name = "张三    ", Type = "二", Result = "成功" });
            foreach (UserNameModel nameStr in nameList)
            {
                string nameReStr = nameStr.Name;
                if (IsHasChinese(nameReStr))
                {
                    nameReStr = Regex.Replace(nameReStr, @"\s", "");
                }
                bool result = isRightChar(nameReStr);
                Console.WriteLine(string.Format("期待结果:[{0}]\t【{1}】\t{2}：\t", nameStr.Result, result ? "XXXXX" : "合法字符", nameStr.Name));
            }
        }

        /// <summary>
        /// 判断是否是非法字符
        /// </summary>
        /// <param name="str">判断是字符</param>
        /// <returns></returns>
        public static Boolean isRightChar(string str)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return true;
            }

            //包含如下字符直接认定为非法字符
            string badstring = "笨蛋,先生,小姐,女士,用户,携程,携程客户,测试,测试订单,奸夫,淫妇,傻逼,咸蛋超人,网上追逃,涉黑案,贩毒集团,人贩子,强奸犯,全家亡,漳州通缉犯,公安部通缉犯,杀人犯,诈骗犯,倒卖妇女,上海市农业生产资料公司,干死你,test,ctrip,ms,mr,mrs";
            string badstringnew = "黑名单值,笨蛋,test,先生,小姐,女士,ctrip,携程,奸夫,淫妇,傻逼,咸蛋超人,1,3,2,0,4,5,6,7,8,9,10,涉黑案,贩毒集团,人贩子,强奸犯,全家亡,漳州通缉犯,公安部通缉犯,杀人犯,诈骗犯,倒卖妇女,上海市农业生产资料公司,携程客户,测试,测试订单,干死你,代理下线,代理价格下掉,马上到有房的话就麻烦确认下,不允许携带代理请下线,要求你们代理下线,华住会法务部立即下线,43466,抓代理立即下线,华住集团法务部立即下线,亚朵酒店法务部请立刻下线,各渠道代理请下线,桔子酒店法务部请立刻下线,桔子法务部立刻下线否则要赔付,下线代理否则客人过来一律不接待,代理给我下掉,43796,请下线所有日期代理价,广州代理下线,请下线所有日期房型和价格谢谢,桔子酒店法务纠察请马上下线,香格里拉法务部立即下线,下线不允许代理后果自负,测式单立马给我全部下线,不允许代理出现请下线,请下线再上线就投诉,测事单立马给我下线,酒店测事立马下线,价格不对 请下线,代理一律到店无房,今日满房请关房,代理请立即下线,侧试单马上下线,不侧试你不高兴,东芝代理下线,陈春风不如你,确认号,确认号码,哦哦";
            string[] sArray = badstringnew.Split(',');
            foreach (var value in sArray)
            {
                if (str.Contains(value))
                {
                    return true;
                }
            }

            //处理多个字符同时出现、如果分割后有一个空字符就说明不合理，比如加孜拉/吐尔德别克/
            string[] sArrayMore = str.Split(new char[7] { '-', '/', '.', '。', '，', '•', ' ' });
            foreach (string strMore in sArrayMore)
            {
                if (string.IsNullOrWhiteSpace(strMore))
                {
                    return true;
                }
            }

            string goodstring = "•,.,·";
            string[] gArray = goodstring.Split(',');

            bool isChinese=IsHasChinese(str);
            if (isChinese)
            {                
                foreach (var value in gArray)
                {
                    ////中文中如果上述字符出现多个，连续，不连续都不对。
                    if (SubstringCount(str, value) > 1)
                    {
                        return true;
                    }
                    ////包含如下如下字符直接认定为合法字符
                    if (str.Contains(value))
                    {
                        return false;
                    }
                }

                if (2 * str.Length == Encoding.Default.GetByteCount(str))
                {
                    str = ToDBC(str);
                }
                char[] charStr = str.ToLower().ToCharArray();
                for (int i = 0; i < charStr.Length; i++)
                {
                    int num = Convert.ToInt32(charStr[i]);
                    if (!IsChineseLetter(num) && num >= 33 && num <= 126)
                    {
                        return true;
                    }
                }
            }
            else
            {
                //包含如下如下字符直接认定为合法字符
                foreach (var value in gArray)
                {
                    if (str.Contains(value))
                    {
                        return false;
                    }
                }
                //全角转换半角
                if (2 * str.Length == Encoding.Default.GetByteCount(str))
                {
                    str = ToDBC(str);
                }

                char[] charStr = str.ToLower().ToCharArray();
                for (int i = 0; i < charStr.Length; i++)
                {
                    //首字符是特殊字符
                    int numStart = Convert.ToInt32(charStr[0]);
                    if ((numStart >= 32 && numStart <= 64) || (numStart >= 91 && numStart <= 96) || (numStart >= 123 && numStart <= 126))
                    {
                        return true;
                    }
                    //末尾字符是特殊字符
                    int numEnd = Convert.ToInt32(charStr[charStr.Length - 1]);
                    if ((numEnd >= 32 && numEnd <= 64) || (numEnd >= 91 && numEnd <= 96) || (numEnd >= 123 && numEnd <= 126))
                    {
                        return true;
                    }
                    int num = Convert.ToInt32(charStr[i]);
                    if ((num > 32 && num <= 44) || (num >= 48 && num <= 64) || (num >= 91 && num <= 96) || (num >= 123 && num <= 126))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        // <summary> 
        /// 计算字符串中子串出现的次数
        /// </summary>
        /// <param name="str">字符串</param>
        /// <param name="substring">子串</param>
        /// <returns>出现的次数</returns>

        static int SubstringCount(string str, string substring)
        {
            if (str.Contains(substring))
            {
                string t_sp = str.Replace(substring, "");
                return (str.Length - t_sp.Length) / substring.Length;
            }
            return 0;
        } 

        /// <summary>
        /// 判断字符的Unicode值是否是汉字
        /// </summary>
        /// <param name="code">字符的Unicode</param>
        /// <returns></returns>
        protected static bool IsChineseLetter(int code)
        {
            bool result = false;
            int chfrom = Convert.ToInt32("4e00", 16);    //范围（0x4e00～0x9fff）转换成int（chfrom～chend）
            int chend = Convert.ToInt32("9fff", 16);

            if (code >= chfrom && code <= chend)
            {
                result = true;     //当code在中文范围内返回true

            }
            else
            {
                result = false;    //当code不在中文范围内返回false
            }

            return result;
        }

        ///转半角的函数(DBC case)  
        ///全角空格为12288，半角空格为32  
        ///其他字符半角(33-126)与全角(65281-65374)的对应关系是：均相差65248//   
        public static string ToDBC(string input)
        {
            char[] array = input.ToCharArray();
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == 12288)
                {
                    array[i] = (char)32;
                    continue;
                }
                if (array[i] > 65280 && array[i] < 65375)
                {
                    array[i] = (char)(array[i] - 65248);
                }
            }
            return new string(array);
        } 

        public static bool IsHasChinese(string inputStr)
        {
            int iLength = inputStr.Length;
            for (int i = 0; i < iLength; i++)
            {
                if ((char)inputStr[i] > 255)
                {
                    return true;
                }
            }
            return false;
        }
        private static void Test9()
        {
            string percentage = "5%";
            double ff = 0;
            if (percentage.EndsWith("%"))
            {
                ff = double.Parse(percentage.Substring(0, percentage.Length - 1)) / 100;
            }

            Console.WriteLine(ff);


            string commissionPercent = "5.00%";
            decimal percentConfig = commissionPercent.EndsWith("%")
                ? Convert.ToDecimal(commissionPercent.Substring(0, commissionPercent.Length - 1)) / 100
                : Convert.ToDecimal(commissionPercent);

            Console.WriteLine(percentConfig);
        }

        private static void Test8()
        {
            string s = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

            string abc = GZipUtility.GZipCompress(s);
            Console.WriteLine(abc);
        }

        private static void Test7()
        {
            int? abc = null;
            string value = Convert.ToString(abc);
            Console.WriteLine("请输入您的值=" + value);

            string origin = "1234566";
            var inputBytes = new byte[origin.Length / 2];
            for (var x = 0; x < inputBytes.Length; x++)
            {
                var i = Convert.ToInt32(origin.Substring(x * 2, 2), 16);
                inputBytes[x] = (byte)i;
            }
        }

        private static void Test6()
        {
            string TraceLogID = UniqueIDHelper.ShrinkGuid();
            Console.WriteLine("请输入您的值=" + TraceLogID);
        }

        private static void Test5()
        {
            List<string> nameList = new List<string>();
            nameList.Add("Bostancıolu/Ali Ibrahim");
            nameList.Add("ツジタ/マキ");
            bool isOk = CheckClientName("EN", nameList);
        }

        private static void Test4()
        {
            List<RateCodeInfo> iList = new List<RateCodeInfo>();
            RateCodeInfo info1 = new RateCodeInfo();
            info1.PropertyID = 123;
            info1.PropertyValueID = 899272;
            RateCodeInfo info2 = new RateCodeInfo();
            info2.PropertyID = 123;
            info2.PropertyValueID = 899274;
            RateCodeInfo info3 = new RateCodeInfo();
            info3.PropertyID = 123;
            info3.PropertyValueID = 899322;
            iList.Add(info1);
            iList.Add(info2);
            iList.Add(info3);
            var list = iList.Where(p => p.PropertyValueID == 899272 || p.PropertyValueID == 899274).ToList();
            Console.WriteLine(list);
        }

        private static void Test3()
        {
            int time = DateTime.Now.Hour;
            bool a = time > 12;

            Console.WriteLine(a);
            TimeSpan _strWorkingDayAM = DateTime.Parse("08:30").TimeOfDay; ;//工作时间上午08:00 
        }
        private static bool CheckClientName(string language, List<string> nameList)
        {
            var result = false;

            if (language.Equals("EN"))
            {
                foreach (var clientname in nameList)
                {
                    if (IsHasChinese(clientname))
                    {
                        result = false;
                        //break;
                    }
                }
            }

            if (nameList == null
                || nameList.Count == 0
                || nameList.Exists(c => string.IsNullOrWhiteSpace(c) || string.IsNullOrWhiteSpace(c.Trim(new char[] { ' ', '/' }))))
            {
                result = false;
            }

            return result;
        }

        ///     检测输入字符串里是否有汉字 (暂放此处) TODO3 放到公用方法里
        /// </summary>
        /// <param name="inputStr">输入字符串</param>
        /// <returns></returns>
        public static bool IsHasChineseA(string inputStr)
        {
            int iLength = inputStr.Length;
            for (int i = 0; i < iLength; i++)
            {
                if ((char)inputStr[i] > 255)
                {
                    return true;
                }
            }
            return false;
        }
        public class RateCodeInfo
        {
            public int PropertyID { get; set; }
            public int PropertyValueID { get; set; }
        }
        private static void getDate()
        {
            Dictionary<int, int> sortedList = new Dictionary<int, int>();
            sortedList.Add(123456, 2);
            sortedList.Add(555, 2);
            sortedList.Add(5522, 2);
            Console.WriteLine(sortedList.ContainsValue(2));
        }
        private static void Test1()
        {
            Dictionary<String, String> sortedList = new Dictionary<string, string>();
            sortedList.Add(PaymentConst.Version, "30");
            sortedList.Add(PaymentConst.Platform, "30");
            sortedList.Add(PaymentConst.ServiceCode, "41003001");
            sortedList.Add(PaymentConst.MerchantID, "30");
            sortedList.Add(PaymentConst.Auth, "30");
            sortedList.Add(PaymentConst.OrderID, "30");
            //sortedList.Add(PaymentConst.RequestID, "0");
            sortedList.Add(PaymentConst.Language, "ZH");
            sortedList.Add(PaymentConst.ClientIP, "30");
            sortedList.Add(PaymentConst.Guid, "30");

            sortedList.Add(PaymentConst.PaymentVersion, "2.0.1");
            sortedList.Add(PaymentConst.InterfaceName, "Create_PaymentBill");
            sortedList.Add(PaymentConst.TransactionID, "30");
            sortedList.Add(PaymentConst.PaymentDescription, "20");
            sortedList.Add(PaymentConst.GuaranteeAmount, "30");
            sortedList.Add(PaymentConst.GuaranteeCurrency, "30");
            sortedList.Add(PaymentConst.Amount, "30");
            sortedList.Add(PaymentConst.CurrencyCode, "30");
            sortedList.Add(PaymentConst.IsPreAuth, "0");
            sortedList.Add(PaymentConst.IsGuarantee, "0");
            sortedList.Add(PaymentConst.CustomerName, "30");
            sortedList.Add(PaymentConst.EnabledPayCatalog, "30");
            sortedList.Add(PaymentConst.EnabledPayway, "30");
            sortedList.Add(PaymentConst.DisabledPayway, "30");
            sortedList.Add(PaymentConst.EnabledCardExpirationDate, "30");
            sortedList.Add(PaymentConst.PayRequestExtend, "30");

            StringBuilder builder = new StringBuilder();
            sortedList = ascendingOrder(sortedList);
            foreach (KeyValuePair<string, string> itemStr in sortedList)
            {
                if (!string.IsNullOrEmpty(itemStr.Value))
                {
                    builder.Append(string.Format("&{0}={1}", itemStr.Key, itemStr.Value));
                }
            }
            Console.WriteLine(builder.ToString());
        }
        private static void Test2()
        {
            int num = 0;
            Interlocked.Increment(ref num);
            Console.WriteLine(num);
            Interlocked.Decrement(ref num);
            Console.WriteLine(num);
            Interlocked.Exchange(ref num, 10);
            Console.WriteLine(num);
            Console.WriteLine(Interlocked.CompareExchange(ref num, 100, 10));
            Console.WriteLine(num); 
        }
        //将集合key以ascii码从小到大排序
        public static Dictionary<string, string> ascendingOrder(Dictionary<string, string> sArray)
        {
            Dictionary<string, string> asciiDic = new Dictionary<string, string>();
            string[] arrKeys = sArray.Keys.ToArray();
            Array.Sort(arrKeys, string.CompareOrdinal);
            foreach (var key in arrKeys)
            {
                string value = sArray[key];
                asciiDic.Add(key, value);
            }
            return asciiDic;
        }

        /// <summary>
        /// 转换百分数为小数
        /// 如：15%=>0.15
        /// 为Null或空时，返回空字符
        /// </summary>
        public static String ConvertToPercentDecimal<T>(T source)
        {
            if (source != null)
            {
                if (!String.Empty.Equals(source.ToString()))
                {
                    decimal result = Convert.ToDecimal(source) / 100;

                    return result.ToString();
                }
                else { return source.ToString(); }
            }
            else
            {
                return String.Empty;
            }
        }
    }
}
